<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            后台管理中心
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/admin/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>轮播管理</cite></a>
              <a><cite>轮播列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
            <table class="layui-table" id="tab">
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>      
                        <th>
                            缩略图
                        </th>
                        <th>
                            图片的站点路径
                        </th>
                        <th>
                            描述
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>         
                </thead>
                <tbody id="x-img">
                {volist name="show" id="vo"}
                    <tr>
                        <td>
                            {$vo.id}号图
                        </td>
                        <td>
                        <div id="layer-photos-demo" class="layer-photos-demo" onclick="">
                             <img  src="{$vo.picture}" width="200" alt="" >
                         </div> 
                        </td>
                        <td >
                          {$vo.picture}
                        </td>
                        <td >
                          {$vo.state}
                        </td>
                        <td class="td-manage">
                          <button class="layui-btn" onclick="banner_add('更新图片','/admin/banner/banner_add?id={$vo.id}','600','500',)"><i class="layui-icon">&#xe608;</i>更新图片</button>
                        </td>
                    </tr>
                    {/volist}
                </tbody>  
            </table>
        <div id="page"></div>
        </div>
        <script src="/admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="/admin/js/x-layui.js" charset="utf-8"></script>
        <script src="/admin/js/jquery.min.js"></script>
        <script>
            layui.use(['laydate','element','laypage','layer'], function(){
                $ = layui.jquery;//jquery
              laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层

              //以上模块根据需要引入

            });
            
            function view(path){
            	var image ="__ROOT__/public/images/banner/"+path;
            	//layer.msg("<img src='"+a+"'/>");
            	//layer.msg('__ROOT__/public/images/banner/'+path);
            	layer.open({
            		  type: 1,
            		  title: false,
            		  closeBtn: 0,
            		  area: '1000px',
            		  skin: 'layui-layer-nobg', //没有背景色
            		  shadeClose: true,
            		  content: "<img src='"+image+"' style='width:1000px'/>"
            		}); 
            	
            }

            //批量删除提交
             function delAll () {
            	 if($("input:checked:not('[name=control_checkbox]')").prop("checked")){
            		 layer.confirm('确认要删除吗？',function(){
                         //捉到所有被选中的，发异步进行删除
                         var arr = $("input:checked").serialize();
                         //layer.confirm(arr);
                         //$("input:checked").parents('tr').remove();
                     $.ajax({
                        	 type:'get',
                        	 url:'__APP__/Banner/delAll',
                        	 data:arr,
                        	 success:function(msg){
                        		 //layer.confirm(msg);
                        		 if(msg=="删除成功"){
                        			 layer.msg('删除成功', {icon: 1});
                        			 var count = $("#count").html();//获取数量值
                        			 var num = $("input:checked:not('[name=control_checkbox]')").length;
                        			 //alert(num);
                                     $("#count").html(count-num);//删除时数量值减选中的数量
                                     $("input:checked:not('[name=control_checkbox]')").parent().parent().remove();
                        		 }
                        	 }
                         }); 
                         
                     });
                 }else{
                 	layer.msg('请选择目标',{icon:5});
                 }
                
             }
             /*添加*/
            function banner_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }
            
            //编辑
            
            function banner_edit(bid){
            	//alert(bid);
            	//return false;
            	layer.open({
            		  type: 2,
            		  title: '编辑',
            		  shadeClose: true,
            		  shade: 0.8,
            		  area: ['455px', '300px'],
            		  content: '__APP__/Banner/banner_edit/bid/'+bid //iframe的url
            		}); 
            }
            /*删除*/
            function banner_del(obj,id){
                layer.confirm('确认要删除吗？',function(index){
                    //发异步删除数据
                    $.ajax({
                    	type:'get',
                    	url:'__APP__/Banner/del',
                    	data:{bid:id},
                    	success:function(msg){
                    		//layer.alert(msg);
                    		if(msg=="OK")
                    		{
                    			$(obj).parents("tr").remove();
                                layer.msg('已删除!',{icon:1,time:1000});
                                var count = $("#count").html();//获取数量值
                                $("#count").html(count-1);//删除时数量值减一
                    		}
                    	}
                    });
                    
                });
            }
            
            
            function banner_stop(obj,id){
            	
            	//var a = $(".bid"+id).text();
            	//window.alert(a);
                layer.confirm('确认要隐藏吗？',function(){
                    //发异步把用户状态进行更改
                  $.ajax({
                    	type:"get",
                    	url:"__APP__/Banner/stop",
                    	data:{isshow:'1',bid:id},
                    	success:function(msg){
                    		//layer.alert(msg);
                    		 if(msg=="隐藏"){
                    			$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="banner_start(this,'+id+')" href="javascript:;" title="启用"><i class="layui-icon">&#xe62f;</i></a>');
                                $(obj).parents("tr").find(".td-status").html('<span class="layui-btn layui-btn-disabled layui-btn-mini">隐藏</span>');
                                $(obj).remove();
                                layer.msg('隐藏!',{icon: 5,time:1000});
                                
                    		}  
                    	}
                    });
                	
                    
                });
            }

            /*启用*/
            
            function banner_start(obj,id){
            	
            	//var a = $(".mid"+id).text();
            	//window.alert(a);
            	//return false;
                layer.confirm('确认要显示吗？',function(){  
                    //发异步把用户状态进行更改
                    $.ajax({
                    	type:"get",
                    	url:"__APP__/Banner/start",
                    	data:{'isshow':0,'bid':id},
                    	success:function(msg){
                    		//layer.alert(msg);
                    		
                    		 if(msg=='显示'){
                    			$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="banner_stop(this,'+id+')" href="javascript:;" title="停用"><i class="layui-icon">&#xe601;</i></a>');
                                $(obj).parents("tr").find(".td-status").html('<span class="layui-btn layui-btn-normal layui-btn-mini">显示</span>');
                                $(obj).remove();
                                layer.msg('显示!',{icon: 6,time:1000});
                             
                    		    }
                    	    }
                    	});
                   
                });
            }
            </script>
            <!-- 复选框 -->
            
            <script type="text/javascript">
            function getCheckedNum(){
            	var count = 0;
            	$(":checkbox[name=compent_checkbox\\[\\]]").each(function(i,e){
            		if($(e).prop('checked')){
            			count++;
            		}
            	});
            	return count;
            }
            
            $(function(){
            		$("[name=control_checkbox]").click(function(){
            			$(":checkbox[name=compent_checkbox\\[\\]]").prop('checked',$(this).prop('checked'));
            		});
            		$(":checkbox[name=compent_checkbox\\[\\]]").click(function(){
            			if(getCheckedNum() == $(":checkbox[name=compent_checkbox\\[\\]]").size()){
            				$("[name=control_checkbox]").prop('checked',true);
            			}else{
            				$("[name=control_checkbox]").prop('checked',false);
            			}
            			
            		});
            	});
            </script>
            
    </body>
</html>